home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
pluginy Firefox
/
398
/
398.xpi
/
chrome
/
forecastfox.jar
/
content
/
ping
/
tracker.js
< prev
Wrap
Text File
|
2010-02-04
|
2KB
|
77 lines
/*------------------------------------------------------------------------------
Copyright (c) 2008 Ensolis, LLC. All Rights Reserved.
----------------------------------------------------------------------------*/
var FFTracker = {
queue: [],
timer: null,
_service: null,
get service() {
if (!this._service) {
var mgr = Components.classes["@ensolis.com/forecastfox/manager-service;1"].
getService(Components.interfaces.ffIManagerService);
this._service = mgr.ping;
}
return this._service;
},
/**
* Main entry point for tracking ui events. This pushes the values into a
* processing queue and starts a timer to delay the actual processing.
*/
trackEvent: function fftracker_trackEvent(category, action, label, value) {
// queue the item to track
var item = {
"type": "event",
"category": category,
"action": action,
"label": label,
"value": value
};
this.queue.push(item);
// start the track timer
if (!this.timer) {
var self = this;
this.timer = window.setTimeout(function() { self.process(); }, 100);
}
},
/**
* Main entry point for tracking a url. This pushes the values into a
* processing queue and starts a timer to delay the actual processing.
*/
trackURL: function fftracker_trackURL(url) {
// queue the item to track
var item = {
"type": "url",
"url": url
};
this.queue.push(item);
// start the track timer
if (!this.timer) {
var self = this;
this.timer = window.setTimeout(function() { self.process(); }, 100);
}
},
process: function fftracker_process() {
this.timer = null;
while (this.queue.length) {
item = this.queue.shift();
if (item.type == "event")
this.service.trackEvent(item.category, item.action, item.label, item.value);
else
this.service.trackURL(item.url);
}
},
/* ::::: Sugar to make tracking easier ::::: */
tooltipLoad: function fftracker_tooltipLoad(group) {
this.trackEvent("tooltip", "load", group);
}
};